package com.ycy.smartcourseselection.controller;

import com.ycy.smartcourseselection.common.PageResVO;
import com.ycy.smartcourseselection.common.ResData;
import com.ycy.smartcourseselection.dto.courseSelection.CoSeDeleteDTO;
import com.ycy.smartcourseselection.dto.courseSelection.CoSelectionDTO;
import com.ycy.smartcourseselection.dto.courseSelection.FileCoSelectionDTO;
import com.ycy.smartcourseselection.dto.courseSelection.FindPageCoSelectionDTO;
import com.ycy.smartcourseselection.dto.student.FindAllStuDTO;
import com.ycy.smartcourseselection.service.CoSelectionService;
import com.ycy.smartcourseselection.vo.courseSelection.CoSelectionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "选课记录管理")
@RestController
@RequestMapping("/coSelection")
public class CoSelectionController {
    @Resource
    private CoSelectionService coSelectionService;

    //分页查课程信息
    @PostMapping("/findPage")
    @ApiOperation(value="选课记录 -- 分页查",notes = "otherParams中的条件可选,支持联查")
    public ResData<PageResVO<CoSelectionVO>> findPageCoSelection(@RequestBody FindPageCoSelectionDTO findPageCoSelectionDTO) {
        return coSelectionService.findPageCoSelection(findPageCoSelectionDTO);
    }
    //增加或修改课程信息
    @PostMapping("/save")
    @ApiOperation(value="选课记录 -- 添加",notes = "选课没有修改功能")
    public ResData<Boolean> saveCoSelection(@RequestBody CoSelectionDTO coSelectionDTO) {
        return coSelectionService.saveCoSelection(coSelectionDTO);
    }
    //假删除课程信息
    @DeleteMapping("/deleteByIds")
    @ApiOperation(value="选课记录 -- 批量删除(真)",notes = "传删除课程的id数组")
    public ResData<Boolean> trueDeleteCoSelectionByIds(@RequestBody CoSeDeleteDTO coSeDeleteDTO) {
        return coSelectionService.trueDeleteCoSelectionByIds(coSeDeleteDTO);
    }

    @GetMapping("/fileExport")
    @ApiOperation("选课记录 -- 表格导出选课学生信息")
    public void coSelectionExport(HttpServletResponse response, FileCoSelectionDTO fileCoSelectionDTO) {
        coSelectionService.coSelectionExport(response, fileCoSelectionDTO);
    }
}
